Glossary Terms


An API Key typically serves as both a secret authentication token and a unique identifier.
The keyword "require" is used to import a module / package into the current JS file.
const http = require("http");
const codes = require('http-status-codes');
const tools = require("./tools");
const rec = require("./shapes/rectangle");
Code that is exported (via "exports") from a module is available to be imported in another JS file (via "require"). Below we export a class and a function.
class Rectangle {
	constructor(aWidth, aHeight) {
		this.width = aWidth;
		this.height = aHeight;
	}
}
function prn(o) {
	console.log(o.toString());
}
exports.Rectangle = Rectangle;
exports.prn = prn;
See module
module
(note: As beginners, we'll use the terms module and package interchangeably)
A Node.js module is basically a JavaScript file with classes, functions or data that can be shared (i.e. imported and used by other JS files).
Modules/packages may be:
(often abbreviated as "req" in code)
The object that carries request info from the web browser to the web server when a request is made
(often abbreviated as "res" in code)
The object that carries the response content (HTML or other) from the web server back to the web browser, after a request is made and the server has finished processing.
A module that provides logic for rendering onto the home web page or other information pages.
The "response.write(aString)" or "res.write(aString)" writes to the response object.
The "response.end()" or "res.end()" message closes the HTTP connection. It is
a good idea to do this when we are done with the response.
The Express "send" message is equivalent to "write" plus "end". Thus, we do not need to send "end" after it.

Gotcha 🐞 We can only use "send" once per connection/request. If we want to do multiple writes, we can again use response write and response end.
The Express get method registers a URL path with an action (or handler function).
Using the "get" method:
app.get("/", homeFct);
app.get("/calc", calcFct);


Web Server Actions
URLURL PathAction
http://localhost:3000/homeFct
http://localhost:3000/calc/calccalcFct
Node.js global objects are available without any imports (i.e., "require" not needed).
An HTML template is a document that has place-holders that are filled-in when the template is resolved.

Template engines are tools to faciliate filling in templates.
Middleware is a function that sits between the client (requester) and server (responder). Middleware has access to the request and response. A middleware function also has access to the next middleware function

The middleware must resolve the function by either

Middleware tasks:

  • May perform any desired code
  • May change request (req) and/or response (res)
  • Must resolve the function in one of two ways:
    • end request-response cycle (i.e., return the result to the client via res.send, res.end, res.json, ...)
    • call next middleware (i.e., call back to passed function param "next" via "next()")












Navigation